let dialogMessageBoxEl = null;
let dialogMessageBoxCloseEl = null;
let dialogMessageBoxBodyEl = null

function dialogMessageBoxCreate(title) {
    dialogMessageBoxEl = document.createElement('div');
    dialogMessageBoxEl.className = 'dialog-message-box';
    const mainEl = document.createElement('div');
    mainEl.className = 'dialog-message-main';
    dialogMessageBoxEl.appendChild(mainEl);
    const headerEl = document.createElement('div');
    headerEl.className = 'dialog-message-main-header';
    const titleEl = document.createElement('div');
    titleEl.className = 'dialog-message-main-title';
    titleEl.innerText = title;
    dialogMessageBoxCloseEl = document.createElement('div');
    dialogMessageBoxCloseEl.className = 'dialog-message-main-close';
    const leftEl = document.createElement('div');
    leftEl.className = 'dialog-message-main-close-left';
    const rightEl = document.createElement('div');
    rightEl.className = 'dialog-message-main-close-right';
    dialogMessageBoxCloseEl.appendChild(leftEl);
    dialogMessageBoxCloseEl.appendChild(rightEl);
    headerEl.appendChild(titleEl);
    headerEl.appendChild(dialogMessageBoxCloseEl);
    dialogMessageBoxBodyEl = document.createElement('div');
    dialogMessageBoxBodyEl.className = 'dialog-message-main-body';
    mainEl.appendChild(headerEl);
    mainEl.appendChild(dialogMessageBoxBodyEl);
    return [dialogMessageBoxEl, dialogMessageBoxCloseEl, dialogMessageBoxBodyEl];

}

function dialogMessageBoxClose(callBackFun) {
    setTimeout(() => {
        callBackFun();
    });
    publicAllowScrolling();
    dialogMessageBoxEl.style.opacity = '0';
    dialogMessageBoxEl.style.transform = 'translateY(-50px)';
    setTimeout(() => {
        dialogMessageBoxEl.style.display = 'none';
    }, 300);
}

function dialogMessageBoxShow(message) {
    publicPreventScrolling();
    //message 要显示的信息，支持html格式的
    dialogMessageBoxBodyEl.innerHTML = message;

    dialogMessageBoxEl.style.display = 'flex';
    setTimeout(() => {
        dialogMessageBoxEl.style.transform = 'translateY(0px)';
        dialogMessageBoxEl.style.opacity = '1';
    });

}

function dialogMessageBoxRun(callBackFun = ()=>{}, title = '提示') {
    dialogMessageBoxCreate(title);
    dialogMessageBoxCloseEl.addEventListener('click', ()=>dialogMessageBoxClose(callBackFun));
    document.body.appendChild(dialogMessageBoxEl);
}